QoS : Network quality of service

更新时间:
2024-05-15
下载文档

QoS : Network quality of service

This module provides QoS management. QoS (Quality of Service) is used to provide different quality data transmission guarantees for different services under limited network bandwidth resources.

QoS service configuration is flexible, with complete functions, and can be set according to different usage scenarios, such as network-based voice call services, online games, and use of high-priority QoS data transmission to ensure smooth voice service and no popping when the network is congested and no distortion.

User can use the following code to import the qos module.

var qos = require('router/qos');

Support

The following shows qos module APIs available for each permissions.

 User ModePrivilege Mode
qos.ip 
qos.tcp 
qos.udp 
qos.get 
qos.delete 

QoS Object

qos.ip(ifname, policy, ipStart, ipEnd, prio[, reliable])

  • ifname {String} Network interface name.
  • policy {String} Policy of this rule.
  • ipStart {String} Starting IP address.
  • ipEnd {String} End IP address.
  • prio {Integer} Priority 0 ~ 7. The higher the number, the higher the priority.
  • reliable {Boolean} Ensuring packets are not dropped during network congestion. default: false.
  • Returns: {Integer} Index number of this rule.

Add a IP QoS rule to the specified network interface.

policy can choose 's' for source address range, 'd' for destination address range, and 'sd' for both address range.

Example

// 'ipStart' address must be less than 'ipEnd'
qos.ip('en1', 'd', '10.0.0.3', '10.0.0.50', 5, false);

qos.tcp(ifname, policy, ipStart, ipEnd, portStart, portEnd, prio[, reliable])

  • ifname {String} Network interface name.
  • policy {String} Policy of this rule.
  • ipStart {String} Starting IP address.
  • ipEnd {String} End IP address.
  • portStart {Integer} Starting TCP port.
  • portEnd {Integer} End TCP port.
  • prio {Integer} Priority 0 ~ 7. The higher the number, the higher the priority.
  • reliable {Boolean} Ensuring packets are not dropped during network congestion. default: false.
  • Returns: {Integer} Index number of this rule.

Add a TCP QoS rule to the specified network interface.

Example

// 'ipStart' address must be less than 'ipEnd'
qos.tcp('en1', 'd', '10.0.0.3', '10.0.0.50', 80, 80, 5, false);

qos.udp(ifname, policy, ipStart, ipEnd, portStart, portEnd, prio[, reliable])

  • ifname {String} Network interface name.
  • policy {String} Policy of this rule.
  • ipStart {String} Starting IP address.
  • ipEnd {String} End IP address.
  • portStart {Integer} Starting UDP port.
  • portEnd {Integer} End UDP port.
  • prio {Integer} Priority 0 ~ 7. The higher the number, the higher the priority.
  • reliable {Boolean} Ensuring packets are not dropped during network congestion. default: false.
  • Returns: {Integer} Index number of this rule.

Add a UDP QoS rule to the specified network interface.

Example

// 'ipStart' address must be less than 'ipEnd'
qos.udp('en1', 'd', '10.0.0.3', '10.0.0.50', 123, 456, 5, false);

qos.get()

  • Returns: {Array} List of all QoS rules added previously.

Each rule is an object in the array, which contains the following properties:

  • ifname {String} Network interface name.
  • index {Integer} Index number of this rule.
  • rule {String} Type of this rule: 'IP', 'TCP' or 'UDP'.
  • policy {String} Policy of this rule.
  • ipStart {String} Starting IP address.
  • ipEnd {String} End IP address.
  • portStart {Integer} Starting TCP or UDP port.
  • portEnd {Integer} End TCP or UDP port.
  • prio {Integer} Priority.
  • reliable {Boolean} Whether to enable reliable reception guarantee.

Example

var rules = qos.get();

console.log(rules);

qos.get(ifname)

  • ifname {String} Network interface name.
  • Returns: {Array} List of all QoS rules for the specified network interface added previously.

Same as qos.get(), only list the rules for the specified network interface.

Example

var rules = qos.get('en1');

console.log(rules);

qos.get(index)

  • index {Integer} Index number of this rule.
  • Returns: {Object} Rule object corresponding to index.

Same as qos.get(), but only get the rule specified by index.

Example

var index = qos.tcp('en1', 'd', '10.0.0.3', '10.0.0.50', 80, 80, 5, false);
var rule = qos.get(index);

console.log(rule);

qos.delete()

  • Returns: {Boolean} Whether the operation was successful.

Delete all QoS rules added in this process.

Example

qos.delete();

qos.delete(ifname)

  • ifname {String} Network interface name.
  • Returns: {Boolean} Whether the operation was successful.

Delete all QoS rule of the specified interface.

qos.delete(index)

  • index {Integer} Index number of this rule.
  • Returns: {Boolean} Whether the operation was successful.

Delete the QoS rule of the specified index number.

Example

var index = qos.tcp('en1', 'd', '10.0.0.3', '10.0.0.50', 80, 80, 5, false);
qos.delete(index);
文档内容是否对您有所帮助?
有帮助
没帮助